<?php

require('configuration.php');
require('function/general.php');

//start session
session_start();

if(isset($_GET['lang']) && '' != $_GET['lang']) {
	$_SESSION['lang'] = $_GET['lang'];
}
else if(isset($_SESSION['lang']) && '' != $_SESSION['lang']){
	; //no need do anything
}
else {
	$_SESSION['lang'] = 'chinese';
}

if(isset($_SESSION['lang']) && '' != $_SESSION['lang']) {
	if('english' == $_SESSION['lang']) {
		include('language/English.php');
	}
	else {
		include('language/Chinese.php');
	}
}
else {
	include('language/Chinese.php');
}

if(MEMBER_SITE_ADMIN === (int)$_SESSION['MM_UserGroup']) {
	$super_admin = true;
	$content_admin = true;
	$pay_member = true;
}
else if(MEMBER_CONTENT_ADMIN === (int)$_SESSION['MM_UserGroup']) {
	$super_admin = false;
	$content_admin = true;
	$pay_member = true;
}
else if(MEMBER_PAID === (int)$_SESSION['MM_UserGroup']) {
	$super_admin = false;
	$content_admin = false;
	$pay_member = true;
}
else {
	$super_admin = false;
	$content_admin = false;
	$pay_member = false;
}

//added by joe, to count visitors. for extra usage, so doesn't use db class
//$shtime  = mktime(date("H")+16, date("i"), date("s"), date("m"), date("d"), date("Y"));
//$shtime = date("Y-m-d H:i:s", $shtime);
$pageName = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$connectjoe = mysql_connect("localhost", DATABASE_USERNAME, DATABASE_PASSWORD);
mysql_select_db(DATABASE_NAME);
$visitCounter = mysql_query("INSERT INTO counter SET remote_host='".$_SERVER['REMOTE_HOST']."', remote_ip='".$_SERVER['REMOTE_ADDR']."', http_referer='".$_SERVER['HTTP_REFERER']."', user_agent='".$_SERVER['HTTP_USER_AGENT']."', page_name='".$pageName."', visit_time_local=now()");

?>
